/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ticketManager.controller;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import ticketManager.ejb.ProblemDAO;
import ticketManager.ejb.ProductDAO;
import ticketManager.ejb.UserDAO;
import ticketManager.model.ManagerUser;
import ticketManager.model.Product;
import ticketManager.model.UserGroup;

/**
 *
 * @author luchenyuxx
 */
@ManagedBean
@RequestScoped
public class InitialDatabaseController {
    @EJB
    ProblemDAO pd;
    @EJB
    UserDAO ud;
    @EJB
    ProductDAO pdd;
    public String initialDatabase(){
        ud.createUser("admin", "admin",UserGroup.ADMIN);
        ud.createUser("manager","manager", UserGroup.MANAGER);
        ud.createUser("user","user", UserGroup.USER);
        ud.createUser("toto", "toto", UserGroup.USER);
        ManagerUser u=ud.getUserByUsername("user");
        Product p=pdd.createProduct("first product");
        pd.createProblem("problem", "first problem", u,p);
        return "initialed";
    }
}
